package com.kefu.call.vo;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.kefu.basic.model.BasicTag;
import com.kefu.call.model.CallTagRel;
import com.kefu.common.context.KefuContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@Data
public class CallTagRelInsertVo {
    @NotEmpty
    @ApiModelProperty("通话id")
    private String callId;

    @ApiModelProperty("通话标签")
    private List<String> basicTags;

    public List<CallTagRel> tagConvert(String callId) {
        List<CallTagRel> list = Lists.newArrayList();
        if (CollUtil.isNotEmpty(basicTags)) {
            for (String tag :
                    basicTags) {
                CallTagRel callTag = new CallTagRel();
                callTag.setCallId(callId);
                callTag.setTagId(tag);
                callTag.setCreateUser(KefuContext.getUid());
                callTag.setCreateTime(KefuContext.getKefuContext().getNow());
                list.add(callTag);
            }
        }
        return list;
    }
}
